package ynu.edu.ky_elm_springboot3.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import ynu.edu.ky_elm_springboot3.po.Business;
import ynu.edu.ky_elm_springboot3.service.BusinessService;

import java.util.List;

@Tag(name = "商家相关接口")
@RestController
@RequestMapping("/BusinessController")
@CrossOrigin(origins = "*", maxAge = 3600)
public class BusinessController {

    @Autowired
    private BusinessService businessService;

    @Operation(summary = "根据订单类型查询商家", security = @SecurityRequirement(name = "Bearer Authentication"))
    @GetMapping("/listBusinessByOrderTypeId")
    public List<Business> listBusinessByOrderTypeId(@RequestParam("orderTypeId") Integer orderTypeId) {
        return businessService.listBusinessByOrderTypeId(orderTypeId);
    }

    @Operation(summary = "根据商家ID查询商家", security = @SecurityRequirement(name = "Bearer Authentication"))
    @GetMapping("/getBusinessById")
    public Business getBusinessById(@RequestParam("businessId") Integer businessId) {
        return businessService.getBusinessById(businessId);
    }
} 